//https://leetcode.cn/problems/reverse-string-ii/
class Solution {
public:
    string reverseStr(string s, int k) {
        int n = s.length();
        for (int i = 0; i < n; i += 2 * k) {
            reverse(s.begin() + i, s.begin() + min(i + k, n));
        }
        return s;
    }
};
//for (int i = 0; i < s.size(); i += 2 * k) {  
//int left = i, right = min(i + k - 1, (int)s.size() - 1);
//while (left < right) {
//    swap(s[left++], s[right--]);
//}
//        }
//        return s;
//    }